package com.yungu.swift.api.route.v1.passenger;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.api.base.BaseApi;
import com.yungu.swift.assets.passenger.model.dto.PassengerMessageDto;
import com.yungu.swift.assets.passenger.model.param.ApiPassengerMsgParam;
import com.yungu.swift.assets.passenger.service.PassengerMessageService;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.model.annotation.ResponseImgOverride;
import com.yungu.swift.utils.ParamUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 描述：
 *
 * @author Zerrion
 * @Time 2016/12/18
 */
@Controller
@RequestMapping(value = "/api/v1/passenger")
@Api(value = "【乘客】【消息】乘客消息中心接口", tags = "乘客信息中心相关操作")
public class MsgApi extends BaseApi {

    @Reference
    private PassengerMessageService passengerMessageService;

    @ResponseImgOverride
    @RequestMapping(value = {"/token/message/list"}, method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    @ApiOperation(value = "获取乘客信息中心列表接口", notes = "")
    public ResponseData<List<PassengerMessageDto>> getList(
            @ApiParam(name = "appid", value = "APP标识") @RequestParam(value = "appid") String appid,
            @ApiParam(name = "nowPage", value = "当前页", required = false) @RequestParam(value = "nowPage", required = false) Integer nowPage,
            @ApiParam(name = "areaID", value = "areaCode") @RequestParam(name = "areaID", required = false) String areaID,
            @ApiParam(name = "adCode", value = "areaCode") @RequestParam(name = "adCode", required = false) String adCode,
            HttpServletRequest request) {
        ApiPassengerMsgParam pasMsgParam = new ApiPassengerMsgParam();
        pasMsgParam.setNowPage(nowPage);
        pasMsgParam.setAppid(appid);
        pasMsgParam.setUserUuid(getUserUid(request));
        pasMsgParam.setAreaID(ParamUtil.defaultIfNull(areaID, adCode));
        return passengerMessageService.queryPasMsgList(pasMsgParam);
    }
}
